#ifndef SIGNALFILTER_H
#define SIGNALFILTER_H

#include "url.h"
#include "sh_global.h"

class ShNet;

class SHSHARED_EXPORT SignalFilter : public QObject
{
    friend class ShNet;
    SignalFilter(QObject *parent = 0);
public:
    /**
     * @brief connect Connect's network signal to local slot of reciever
     * @param signalUrl smth like this: home_net/timer/timeout
     * @param reciever
     * @param slot
     */
    void connect(const Url &signal, QObject *reciever, const char *slot);
    /**
     * @brief disconnect Disconnect's network signal from local slot
     * @param signal
     * @param reciever
     * @param slot
     * This function must be called with the same arguments as connect
     */
    //void disconnect(const Url &signal, QObject *reciever, const char *slot);

private:
    void filter(const Url &signalUrl, QVariantList &parameters);

    typedef struct {
        Url signal;
        bool isEmpty; // after disconnect called, isEmpty = true
        QObject *reciever;
        const char *slot;
        QVector<int> parameterTypes;
    } filter_t;
    QVector<filter_t> m_filters;
    // after disconnet called, index of empty entry (m_filters) goes here,
    // if item is last, it will be removed, otherwise reused later
    QVector<int> m_emptyFilters;
    void *m_parameters[11]; // max 10 parameters ?
};

#endif // SIGNALFILTER_H
